﻿using ASPNetPatterns.Controllers;
using System;
using System.Threading.Tasks;
using System.Web.UI;

namespace ASPNetPatterns
{
    public partial class Default : System.Web.UI.Page
    {
        IdentityAsp ia;
        IdentityAsp IA
        {
            get
            {
                if (ia == null)
                    ia = new IdentityAsp();
                return ia;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Unnamed1_Click(object sender, EventArgs e)
        {
            PageAsyncTask asynctask = new PageAsyncTask(taskhandler);
            Page.RegisterAsyncTask(asynctask);
            Page.ExecuteRegisteredAsyncTasks();

        }

        private System.Threading.Tasks.Task taskhandler(System.Threading.CancellationToken arg)
        {
            //return IA.BorrarUsuario("pablini");
            return Task.Factory.StartNew(() => { IA.RegistrarUsuario("pablinis2","passwords"); });
        }
    }
}